<a href='http://github.com/angular/angular.js/edit/master/src/ng/compile.js' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this doc</a>



<a href='http://github.com/angular/angular.js/tree/master/src/ng/compile.js#L498' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">$compileProvider</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
  <li>
    <a href="api/ng/service/$compile">- $compile</a>
  </li>

    <li>
      - provider in module <a href="api/ng">ng</a>
    </li>
  </ol>
</header>



<div class="api-profile-description">
  
</div>




<div>
  

    

  <h2 id="usage">Usage</h2>
    
      <p><code>$compileProvider();</code></p>


    

    
    
    

  
<h2>Methods</h2>
<ul class="methods">
  <li id="directive">
    <h3><p><code>directive(name, directiveFactory);</code></p>

</h3>
    <div><p>Register a new directive with the compiler.</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        name
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a><a href="" class="label type-hint type-hint-object">Object</a>
      </td>
      <td>
        <p>Name of the directive in camel-case (i.e. <code>ngBind</code> which
   will match as <code>ng-bind</code>), or an object map of directives where the keys are the
   names and the values are the factories.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        directiveFactory
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-function">function()</a><a href="" class="label type-hint type-hint-array">Array</a>
      </td>
      <td>
        <p>An injectable directive factory function. See
   <a href="guide/directive">directive</a> for more info.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-ng">ng.$compileProvider</a></td>
    <td><p>Self for chaining.</p>
</td>
  </tr>
</table>
    

  </li>
  
  <li id="aHrefSanitizationWhitelist">
    <h3><p><code>aHrefSanitizationWhitelist([regexp]);</code></p>

</h3>
    <div><p>Retrieves or overrides the default regular expression that is used for whitelisting of safe
urls during a[href] sanitization.</p>
<p>The sanitization is a security measure aimed at prevent XSS attacks via html links.</p>
<p>Any url about to be assigned to a[href] via data-binding is first normalized and turned into
an absolute url. Afterwards, the url is matched against the <code>aHrefSanitizationWhitelist</code>
regular expression. If a match is found, the original url is written into the dom. Otherwise,
the absolute url is prefixed with <code>&#39;unsafe:&#39;</code> string and only then is it written into the DOM.</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        regexp
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-regexp">RegExp</a>
      </td>
      <td>
        <p>New regexp to whitelist urls with.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-regexp">RegExp</a><a href="" class="label type-hint type-hint-ng">ng.$compileProvider</a></td>
    <td><p>Current RegExp if called without value or self for
   chaining otherwise.</p>
</td>
  </tr>
</table>
    

  </li>
  
  <li id="imgSrcSanitizationWhitelist">
    <h3><p><code>imgSrcSanitizationWhitelist([regexp]);</code></p>

</h3>
    <div><p>Retrieves or overrides the default regular expression that is used for whitelisting of safe
urls during img[src] sanitization.</p>
<p>The sanitization is a security measure aimed at prevent XSS attacks via html links.</p>
<p>Any url about to be assigned to img[src] via data-binding is first normalized and turned into
an absolute url. Afterwards, the url is matched against the <code>imgSrcSanitizationWhitelist</code>
regular expression. If a match is found, the original url is written into the dom. Otherwise,
the absolute url is prefixed with <code>&#39;unsafe:&#39;</code> string and only then is it written into the DOM.</p>
</div>

    
    <h4>Parameters</h4>
    
<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        regexp
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-regexp">RegExp</a>
      </td>
      <td>
        <p>New regexp to whitelist urls with.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-regexp">RegExp</a><a href="" class="label type-hint type-hint-ng">ng.$compileProvider</a></td>
    <td><p>Current RegExp if called without value or self for
   chaining otherwise.</p>
</td>
  </tr>
</table>
    

  </li>
  </ul>
  
  



  
</div>


